﻿using System;
using System.IO;
using System.Reflection;
using System.Windows.Controls;
using System.Windows.Markup;
using StockholmsStad.Utilities.Enums;
using StockholmsStad.Utilities.Exceptions;
using StockholmsStad.Windows.UI.Infrastructure.Models;
using StockholmsStad.Windows.UI.Modules.MainModule.Interfaces;

namespace StockholmsStad.Windows.UI.Modules.MainModule.Services
{
    public class MenuService : IMenuService
    {

        public MenuModel LoadMenu()
        {
            return new MenuModel();
        }

        private void InitializeMenu()
        {
            var filePath = @"../Resources/Menu.xaml";
            var menuFile = Path.Combine(Assembly.GetExecutingAssembly().Location, filePath);

            try
            {
                if (File.Exists(menuFile))
                {
                    using (var s = new FileStream(menuFile, FileMode.Open))
                    {
                        var menu = XamlReader.Load(s, new ParserContext()) as Menu;
                        if (menu != null)
                        {
                            //mainWindow.Children.Insert(0, menu);
                            //menu.Background = Brushes.Transparent;
                            //DockPanel.SetDock(menu, Dock.Top);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw new StockholmStadApplicationException(ApplicationErrorCode.ApplicationRuntimeException, Severity.Low, e);
            }
        }


    }
}